import {Switch,Route,Redirect} from 'react-router-dom'

function RouterView(props){
    const {routes} = props
    return <Switch>
        {
            routes.map((item,index)=>{
                if(item.component){
                    return <Route key={index} exact={item.exact} path={item.path} component = {item.component} />
                }else{
                    return <Route key={index} exact={item.exact} path={item.path}>
                        <Redirect to={item.redirect} />
                    </Route>
                }


            })
        }
    </Switch>
}

export default RouterView